package com.test.dao.impl;

import com.test.dao.BaseDao;
import com.test.dao.HistoryDao;
import com.test.pojo.Feedback;
import com.test.pojo.History;

import java.util.List;
import java.util.Map;

public class HistoryDaoImpl extends BaseDao implements HistoryDao {

    @Override
    public int addHistory(History history) {
        String sql = "insert into history values(DEFAULT,?,?,?,?,?)";
        return baseUpdate(sql, history.getUsername(), history.getImageUrl(), history.getResponseData(), history.getRisks(), history.getFormattedTime());
    }

    @Override
    public int deleteHistory(Integer id) {
        String sql = "delete from history where id = ?";
        return baseUpdate(sql, id);
    }

    @Override
    public List<History> findAllHistory() {
        String sql = "select * from history";
        return baseQuery(History.class, sql);
    }

    @Override
    public List<History> findHistoryById(Integer id) {
        String sql = "select * from history where id = ?";
        return baseQuery(History.class, sql, id);
    }
}
